package com.shuyun.xxx.guava.practice;

import org.junit.Test;

import java.util.concurrent.Semaphore;

/**
 * Created by goodb on 2017/5/21.
 */
public class SemaphoreTest {
    private Semaphore semaphore = new Semaphore(3);
    @Test
    public void run(){
        for(int i = 0; i < 10; i++){
            new Runnable(){
                @Override
                public void run() {
                    try {
                        semaphore.acquire();
                        System.out.println("do working");
                        semaphore.release();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            };
        }
    }
}
